import { ApiProperty } from '@nestjs/swagger'
import { IsNotEmpty, IsOptional, IsString, Length } from 'class-validator'

export class LoginDto {
  /** 验证码 */
  @ApiProperty({
    required: false
  })
  @IsOptional()
  @IsString()
  code?: string

  /** 用户名 */
  @ApiProperty({ required: true })
  @IsString()
  @Length(2, 10, { message: '用户名长度在2位到10之间' })
  @IsNotEmpty({ message: '用户名不能为空' })
  username: string

  /** 密码 */
  @ApiProperty({ required: true })
  @IsString()
  @IsNotEmpty({ message: '密码不能为空' })
  @Length(5, 20)
  password: string
}

export class ClientInfoDto {
  ipaddr: string
  userAgent: string
  browser: string
  os: string
  loginLocation: string
}
